<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<!-- HTML file produced from file: manual.tex --
 -- using Hyperlatex v 2.3.1 (c) Otfried Cheong--
 -- on Emacs 21.4 (patch 15) "Security Through Obscurity" XEmacs Lucid, Fri Dec  3 20:36:28 2004 -->
<HEAD>
<TITLE>Scheme 48 Manual -- Raising exceptions from external code</TITLE>

</HEAD><BODY BGCOLOR="#ffffff">
<EM>Scheme 48 Manual</EM> | <A HREF="s48manual.html#top_node">Contents</A> | In Chapter: <A HREF="s48manual_65.html">Mixing Scheme 48 and C</A><BR>Previous: <A HREF="s48manual_76.html">Raising exceptions from external code</A> | Next: <A HREF="s48manual_76.html">Raising exceptions from external code</A>
<H2>Raising exceptions from external code</H2>

<P>The following macros explicitly raise certain errors, immediately
 returning to Scheme&nbsp;48.
Raising an exception performs all
 necessary clean-up actions to properly return to Scheme&nbsp;48, including
 adjusting the stack of protected variables.
<P><UL><LI><CODE>s48_raise_scheme_exception(int type, int nargs, ...)</CODE>
</UL>
<P><CODE>s48_raise_scheme_exception</CODE> is the base procedure for
 raising exceptions.
<CODE>type</CODE> is the type of exception, and should be one of the
 <CODE>S48_EXCEPTION_</CODE>...constants defined in <CODE>scheme48arch.h</CODE>.
<CODE>nargs</CODE> is the number of additional values to be included in the
 exception; these follow the <CODE>nargs</CODE> argument and should all have
 type <CODE>s48_value</CODE>.
<CODE>s48_raise_scheme_exception</CODE> never returns.
<P>The following procedures are available for raising particular
 types of exceptions.
Like <CODE>s48_raise_scheme_exception</CODE> these never return.
<P><UL><LI><CODE>s48_raise_argument_type_error(s48_value)</CODE>
<LI><CODE>s48_raise_argument_number_error(int nargs, int min, int max)</CODE>
<LI><CODE>s48_raise_range_error(long value, long min, long max)</CODE>
<LI><CODE>s48_raise_closed_channel_error()</CODE>
<LI><CODE>s48_raise_os_error(int errno)</CODE>
<LI><CODE>s48_raise_out_of_memory_error()</CODE>
</UL>
<P>An argument type error indicates that the given value is of the wrong
 type.
An argument number error is raised when the number of arguments, <CODE>nargs</CODE>,
 should be, but isn't, between <CODE>min</CODE> and <CODE>max</CODE>, inclusive.
Similarly, a range error indicates that <CODE>value</CODE> is not between
 between <CODE>min</CODE> and <CODE>max</CODE>, inclusive.
<P>The following macros raise argument type errors if their argument does not
 have the required type.
<CODE>S48_CHECK_BOOLEAN</CODE> raises an error if its argument is neither
 <CODE>#t</CODE> or <CODE>#f</CODE>.
<P><UL><LI><CODE>void S48_CHECK_BOOLEAN(s48_value)</CODE>
<LI><CODE>void S48_CHECK_SYMBOL(s48_value)</CODE>
<LI><CODE>void S48_CHECK_PAIR(s48_value)</CODE>
<LI><CODE>void S48_CHECK_STRING(s48_value)</CODE>
<LI><CODE>void S48_CHECK_INTEGER(s48_value)</CODE>
<LI><CODE>void S48_CHECK_CHANNEL(s48_value)</CODE>
<LI><CODE>void S48_CHECK_BYTE_VECTOR(s48_value)</CODE>
<LI><CODE>void S48_CHECK_RECORD(s48_value)</CODE>
<LI><CODE>void S48_CHECK_SHARED_BINDING(s48_value)</CODE>
</UL>
<P><P>
  
Previous: <A HREF="s48manual_76.html">Raising exceptions from external code</A> | Next: <A HREF="s48manual_76.html">Raising exceptions from external code</A></BODY></HTML>
